;
(function() {
	window.onload = function() {
		var itemArray = new Array("教师管理", "学生管理", "专业管理", "课程管理", "调查项目管理", "调查内容管理");
		var itemdetail=new Array("query","delete","insert","update");
		for(var i = 0; i < itemArray.length; i++) {
			$('.last').before(
				'<div class="bar"><i class="fa fa-database"></i> ' + itemArray[i] + '</div>' +
				'<ul>' +
				'<li><a href="query.html" target="rightFrame" title="查询信息"><i class="fa fa-caret-right"></i>查询信息</a></li>' +
				'<li><a href="delete.html" target="rightFrame" title="删除信息"><i class="fa fa-caret-right"></i>删除信息</a></li>' +
				'<li><a href="insert.html" target="rightFrame" title="增加信息"><i class="fa fa-caret-right"></i>增加信息</a></li>' +
				'<li><a href="update.html" target="rightFrame" title="修改信息"><i class="fa fa-caret-right"></i>修改信息</a></li></ul>'
			);
		}

		$("#left div").each(function(i) {
			var _this_ = this;
			_this_.id = i;
		});

		$('#left ul').each(function(i) {
			var _this_ = this;
			_this_.id = i;
			$(_this_).find('li').each(function(index){
				var _lithis_=this;
				$(_lithis_).addClass(itemdetail[index]);
			});
		});
	}

	var isUnfold = true;
	$('#left').on("click", ".bar", function() {
		var _this_ = this,
			divID = $(_this_).attr("id");
		if(isUnfold) {
			isUnfold = false;
			ulUnfold(divID);
		}
	});

	function ulUnfold(index) {
		var isFold = true;
		ulcleal = null;
		$('#left ul').each(function() {
			var _thisclear_ = this;
			if($(_thisclear_).css("height") == "100px") {
				ulcleal = $(_thisclear_).attr("id");
				$(_thisclear_).animate({height:0},500);
				return false;
			}
		});

		if(ulcleal === index) {
			isFold = false;
		}

		if(isFold) {
			$('#left ul').each(function() {
				var _this_ = this;
				if($(_this_).attr('id') === index) {
					$(_this_).animate({
						height: 100
					}, 500);
				}
			});
		}
		isUnfold = true;
		isFold = true;
	}

    $('body').on('click','span',function(){
    	$('#left ul').each(function() {
			var _allclear_ = this;
			if($(_allclear_).css("height") == "100px") {
				$(_allclear_).animate({height:0},500);
			}
		});
    });
    
    
    $('body').on("click",".query",function(){
    	var _this_=this,
    	    curid=$(_this_).parent().attr("id");
    	    $.ajax({
    	    	type:"get",
    	    	url:"SetProduceHtml",
    	    	async:true,
    	    	data:{"queryid":curid}
    	    });
    });
    
    $('body').on("click",".delete",function(){
    	var _this_=this,
    	    curid=$(_this_).parent().attr("id");
    	 $.ajax({
    	    	type:"get",
    	    	url:"SetProduceHtml",
    	    	async:true,
    	    	data:{"deleteid":curid}
    	    });
    });
    
    $('body').on("click",".insert",function(){
    	var _this_=this,
    	    curid=$(_this_).parent().attr("id");
    	    
    	    $.ajax({
    	    	type:"get",
    	    	url:"SetProduceHtml",
    	    	async:true,
    	    	data:{"insertid":curid}
    	    });
    });
    
    $('body').on("click",".update",function(){
    	var _this_=this,
    	    curid=$(_this_).parent().attr("id");
    	 $.ajax({
    	    	type:"get",
    	    	url:"SetProduceHtml",
    	    	async:true,
    	    	data:{"updateid":curid}
    	    });
    });
    
})();





























